The Integration of the Unity Game Engine and Mathematica

Not Just for Games Anymore

George E. Danner

Business Laboratory LLC

{}

Unity and Mathematica

Mathematica has great visualization capability on its own, but ...

Unity was designed for game development - it is "purpose built" for highly realistic visualizations

"Mathematica is the writer. Unity is the director and film studio." -- Alan Savoy

Inspired by last year' s talk by Todd Gayley and Luc Barthelet

Repeating our general theme of integration

Possible Architectures

Direct Link via Unity Link

Advantages :

Can drive the scene in real time

Can get feedback back from the Unity scene

Disadvantages

Deployment

Asynchronous Through a Script File

The Script Structure

The script is a list of commands for the actors; the scene is assumed to be there

Minimal information approach : The script tells Unity "move actor to point B"

{"Time"->55,"Agents"->{{"Command"->"Move","Name"->"HeloBox3","Destination"->"Helo Target 4"}},"Data"->{"Compliance"->{"Value"->0.024714055855818096`,"Plot"->},"LogisticCost"->{"Value"->7.857415961472272`,"Plot"->},"CostPerUnit"->{"Value"->0.017781566615731326`,"Plot"->}}},{"Time"->60,"Data"->{"Compliance"->{"Value"->0.8918864995697339`,"Plot"->},"LogisticCost"->{"Value"->0.7392334200539388`,"Plot"->},"CostPerUnit"->{"Value"->3.2644363414378086`,"Plot"->}}},{"Time"->62,"Agents"->{{"Command"->"Move","Name"->"Boat Basket5","Destination"->"rig 4 boat dock"}}},{"Time"->64,"Agents"->{{"Command"->"Move","Name"->"HeloBox5","Destination"->"Helo Target 3"},{"Command"->"Move","Name"->"Boat Basket3","Destination"->"rig 3 boat dock"},{"Command"->"Move","Name"->"Boat Basket2","Destination"->"rig 5 boat dock"}}},{"Time"->65,"Data"->{"Compliance"->{"Value"->0.7275743954573006`,"Plot"->},"LogisticCost"->{"Value"->18.80404549322128`,"Plot"->},"CostPerUnit"->{"Value"->2.084091379474178`,"Plot"->}}},{"Time"->67,"Agents"->{{"Command"->"Move","Name"->"Boat Basket1","Destination"->"rig 1 boat dock"}}},{"Time"->68,"Agents"->{{"Command"->"Move","Name"->"HeloBox4","Destination"->"Helo Target 5"}}},{"Time"->70,"Agents"->{{"Command"->"Move","Name"->"Boat Basket4","Destination"->"rig 1 boat dock"}},"Data"->{"Compliance"->{"Value"->0.7500202901145383`,"Plot"->},"LogisticCost"->{"Value"->18.856492435101714`,"Plot"->},"CostPerUnit"->{"Value"->9.937496919214276`,"Plot"->}}}

Dealing with embedded graphics in the script file was a big challenge!

(but we solved it)

Fragment of the actual JSON file :

{"Command":"Move","Name":"Boat Basket1","Destination":"rig 1 boat dock"}

],"Data":{"Compliance":{"Value":0.95,"Plot":"iVBORw0KGgoAAAANSUhEUgAAAQAAAACACAYAAADktbcKAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA\nPHRFWHRTb2Z0d2FyZQBDcmVhdGVkIHdpdGggdGhlIFdvbGZyYW0gTGFuZ3VhZ2UgOiB3d3cud29s\nZnJhbS5jb21coqaFAAAAIXRFWHRDcmVhdGlvbiBUaW1lADIwMTQ6MTA6MDkgMTE6MTM6MDjIffJ8\nAAABG0lEQVR4nO3WoXFCURCG0f/F4RCxkVhqYbCodJBUwBMYHB2AwSNTQSYyHZAO0gAzFw1BZtgZ\n3jly1Sf27twEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAA4D+1fbatT2vrHNtn3qp7qNFVB3B/7SPLfKW/GE6z6eZ5rymiigMwQG2V35wy\nvp53vX0YmqfqAArcePwZ5ef+IVRzAIboJYc/s+d8F5RQzJdvoNo+2xwzyynjTLLrFnmtbgIAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAe\nyBluUxwLixqKywAAAABJRU5ErkJggg==\n"}

The Animation

Two Examples :

Offshore marine/aviation logistics

Unconventional oil & gas drilling

This allowed us to work with the Particle System in Unity

Planned :

The London Underground

What We' ve Learned

Mathematica is an excellent language for building complex system animations

Unity is currently poor at drawing graphs; better to do that in Mathematica

We attended UNITE (Unity’s User Conference) this year in Seattle to get more information about future versions

Possible Applications of Mathematica - Unity Integration

Medical imaging and reconstruction

Sports analysis - replaying key game situations

Manufacturing and logistics

Large scale infrastructure projects

Education - teaching almost anything

The Future

More elaborate Heads Up Displays (HUDs)

Master the deployment challenge of the direct arcitecture

Programmatic control of the camera and lighting effects

Virtual reality